﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AnesSystem.Model;
using System.Threading;
using Common;
using AnesSystem.Models;

namespace AnesSystem.ViewModels
{
    public class SysMainBottomCtrlViewModel : BaseViewModel<SysMainBottomCtrlViewModel>
    {
        #region Variables

        private string _nowTime;

        private string _scale;

        private double _scaleDouble;

        #endregion

        #region Constructor

        public SysMainBottomCtrlViewModel()
        {
            Scale = "100%";
            ScaleDouble = 1;
            GetNowTime();
        }

        #endregion

        #region Properties

        public Hospital Hospital
        {
            get
            {
                return DataManager.Instance.CurrentHospital;
            }
        }

        public ConfigOperationRoomModel Room
        {
            get
            {
                return DataManager.Instance.CurRoom;
            }
        }

        public Common.LocalXMLModel LocalXMLModel
        {
            get
            {
                return ClientAndServerHelper.Instance.LocalXMLContent;
            }
        }

        public string NowTime
        {
            get
            {
                return _nowTime;
            }

            set
            {
                _nowTime = value;
                RaisePropertyChanged("NowTime");
            }
        }

        public string Scale
        {
            get
            {
                return _scale;
            }
            set
            {
                _scale = value;
                RaisePropertyChanged("Scale");
            }
        }

        public double ScaleDouble
        {
            get
            {
                return _scaleDouble;
            }

            set
            {
                _scaleDouble = value;
            }
        }

        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods

        private void GetNowTime()
        {
            Task.Factory.StartNew(delegate
            {
                while (true)
                {
                    NowTime = DateTime.Now.ToString(DateFormat.DATE_FORMAT_STR_YMDHMS);
                    Thread.Sleep(1000);
                }
            });
        }

        #endregion

        #region Public/Protected Methods

        public void Excute(string command)
        {
            switch (command)
            {
                case "hy":
                    if (PrintTemplate.PrintVisul != null)
                    {
                        (PrintTemplate.PrintVisul as PrintTemplate).HyScale();
                        Scale = "100%";
                    }
                    break;
            }
        }

        #endregion

        #region EventHandlers

        #endregion
    }
}
